package com.yykj.hospital.server.controller;

import com.yykj.common.vo.ResultVO;
import com.yykj.hospital.client.dto.DoctorDTO;
import com.yykj.hospital.client.dto.HospitalOfficerDTO;
import com.yykj.hospital.client.dto.open.OpenDoctorDTO;
import com.yykj.hospital.client.form.open.OpenDoctorSearchForm;
import com.yykj.hospital.server.service.HospitalDoctorService;
import com.yykj.hospital.server.service.HospitalService;
import com.yykj.hospital.server.service.open.OpenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/open/api/proto")
@Slf4j
@Api(tags = {"开方平台接口"})
public class ProtoOpenPlatformController {

    @GetMapping("/officer/list")
    @ApiOperation("职称--列表")
    public ResultVO<List<HospitalOfficerDTO>> listHospitalOfficer(@RequestParam(name = "hospitalId") Integer hospitalId){
        List<HospitalOfficerDTO> list = hospitalService.listHospitalOfficer(hospitalId);
        return ResultVO.success(list);
    }

    @GetMapping("/doctor/info/{doctorId}")
    @ApiOperation("医生详情")
    public ResultVO<OpenDoctorDTO> doctorInfo(@PathVariable String doctorId){
        DoctorDTO info = hospitalDoctorService.info(doctorId);
        OpenDoctorDTO openDoctorDTO = new OpenDoctorDTO();
        BeanUtils.copyProperties(info,openDoctorDTO);
        return ResultVO.success(openDoctorDTO);
    }

    @PostMapping("/doctor/search")
    public ResultVO openSearchDoctor(@RequestBody OpenDoctorSearchForm form){
        return ResultVO.success(openService.openSearchDoctor(form));
    }

    private OpenService openService;

    private HospitalService hospitalService;

    private HospitalDoctorService hospitalDoctorService;

    @Autowired
    public void setOpenService(OpenService openService) {
        this.openService = openService;
    }

    @Autowired
    public void setHospitalService(HospitalService hospitalService) {
        this.hospitalService = hospitalService;
    }
    @Autowired
    public void setHospitalDoctorService(HospitalDoctorService hospitalDoctorService) {
        this.hospitalDoctorService = hospitalDoctorService;
    }
}
